public class TongdaoRe {

    public static void Jiexi(String shuju) {
        String yingda = shuju.substring(0, 2);
        System.out.println("是否需要应答为01需要 00不需要:" + yingda);
        String yuanyu = shuju.substring(2, shuju.length());
        System.out.println("原语为:" + yuanyu);

        String MAC = shuju.substring(2, 10);
        System.out.println("MAC 为:" + MAC);
        String MACLLC = shuju.substring(10, 12);
        System.out.println("MAC 控制域 为:" + MACLLC);
        String llc = shuju.substring(12, 14);
        System.out.println("LLC控制域 为:" + llc);
        String duanzitou = shuju.substring(14, 16);
        System.out.println("段字头 为:" + duanzitou);


        String TAPDUptional  = shuju.substring(16, 18);
        System.out.println("T-APDU&0ptional: 为:" + TAPDUptional);
        String DID = shuju.substring(18, 20);
        System.out.println("DID 为:" + DID);

        String ActionType = shuju.substring(20, 22);
        System.out.println("ActionType为:" + ActionType);

        String ChannelRe = shuju.substring(22, 24);
        System.out.println("ChannelRe为:" + ChannelRe);

        String ChannalID = shuju.substring(24, 26);
        System.out.println("channelID为:" + ChannalID);


        if (shuju.length()>26){
            String allnum = shuju.substring(26, 28);
            System.out.println("指令总数为:" + allnum);
            //指令为第几个+长度+数据
            String zhiling = shuju.substring(26, shuju.length()-2);
            System.out.println("（总数1字节+长度1字节+数据N字节）指令 为:" + zhiling);
            int allnum2 = Integer.parseInt(String.valueOf(allnum), 16);
            String nowzhiling=zhiling.substring(2,zhiling.length());
            System.out.println("指令为:" + nowzhiling);
            int index=0;
            for (int i = 0; i <allnum2 ; i++) {
                 int value=i+1;



                String len = nowzhiling.substring(index, index+2);
                index=index+2;
                System.out.println("第"+value+"个指令的十六进制长度为:" + len);
                int decimal = Integer.parseInt(len, 16);
                System.out.println("第"+value+"个指令的十进制长度为:" + decimal);
                String data = nowzhiling.substring(index, index+decimal*2);
                System.out.println("第"+value+"个指令为:" + data);
                index=index+decimal*2;
            }

            String obuzhuangtai = shuju.substring(shuju.length()-2, shuju.length());
            System.out.println("OBU处理状态为:" + obuzhuangtai);
        }else {
            System.out.println("当前指令为:SetMMi指令或者EventReport指令" );
        }






    }
}
